﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//using System.Data.SqlClient;
//using System.Data;

using MySql.Data.MySqlClient;
using MySql.Data;

namespace AST.DAL
{
    public class ConnService:IDisposable 
    {
        public MySqlConnection _sqlConnection = null;

        public ConnService()
        {
            if (_sqlConnection == null)
            {
                string sqlconnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnString"];
                _sqlConnection = new MySqlConnection(sqlconnectionString);
            }

            //if (_sqlConnection.State == ConnectionState.Closed)
            _sqlConnection.Open();
        }

        public MySqlConnection SqlConnection
        {
            get
            {
                return _sqlConnection;
            }
        }

        public void Dispose()
        {
            if (_sqlConnection != null)
            {
                //if (_sqlConnection.State == ConnectionState.Open)
                _sqlConnection.Close();
            }
        }
    }
}
